<?php
namespace app\admin\model;
use think\model;
use think\Db;
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2018/8/13
 * Time: 10:37
 */
class BannerModel extends Model{
    protected $name = 'banner';
    /**
     * 根据搜索条件获取用户列表信息
     */
    public function getUsersByWhere($od, $Num, $limit)
    {
        return $this->alias ('a')
            ->page($Num, $limit)
            ->order($od)
            ->select();
    }
    public function batchDelBanner($param){
        Db::startTrans();// 启动事务
            $res = $this->where('banner_id','IN',$param)->delete();
            if($res){
                Db::commit();
                writelog(session('uid'),session('username'),'批量删除成功',1);
                return ['code' => 200, 'data' => '', 'msg' => '批量删除成功'];
            }else{
                Db::rollback();
                writelog(session('uid'),session('username'),'批量删除失败',2);
                return ['code' => 100, 'data' => '', 'msg' => '批量删除失败'];
            }
    }
}